<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo F('web_page_title');?></title>
<?php TPL::plugin('include/css_link');?>
<?php TPL::plugin('include/js_link');?>
</head>
<body id="follow">
	<div id="wrap">
		<div class="wrap-in">
			<?php TPL::plugin('include/header');?>
			<div id="container">
				<div class="extra">
					<!-- 站点导航 开始 -->
					<?php Xpipe::pagelet('common.siteNav');?>
					<!-- 站点导航 结束 -->
				</div>
				<div class="content">
					<div class="main-wrap">
						<div class="main">
                        	<div class="main-bd">
                        		<!-- 分组用户列表TAB开始 -->
                        		
                        	<div class="user-list-search">
	<div class="tab-box">
		<div class="tab-s2">						
			<span <?php echo $gid == 0 ? 'class="current"' : ''; ?>><span><a href="/index.php?m=gtstar">全部</a></span></span>
			 <?php foreach ($groups as $group) { ?>
			<span <?php echo $gid == $group['id'] ? 'class="current"' : ''; ?>><span><a href="/index.php?m=gtstar&amp;gid=<?php echo $group['id'];?>"><?php echo $group['group_name'];?></a></span></span>
				<?php } ?>
			
		</div>
	</div>
    
	<?php
		if (isset($users) && is_array($users) && !empty($users)) {
		echo '<div class="user-list-wrap">';
	//关注列表
	foreach ($users as $star) {

		$uid = isset($star['uid']) ? $star['uid'] : $star['id'];
		$nick = isset($star['screen_name']) ? F('escape', $star['screen_name']) : F('escape', $star['nickname']);
		$user_img = isset($star['profile_image_url']) ? F('profile_image_url', $star['profile_image_url']) : F('profile_image_url', $star['uid']);
		if(isset($star['remark'])){
			$remark = F('escape', $star['remark']);
		}elseif(isset($star['description'])){
			$remark = F('escape', $star['description']);
		}else{
			$remark = '';
		}
		
		$rel_uid = $star['rel_uid'];
		$rel_nick = isset($star['screen_name']) ? F('escape', $star['screen_name']) : F('escape', $star['rel_nickname']);
		$rel_user_img = isset($star['profile_image_url']) ? F('profile_image_url', $star['profile_image_url']) : F('profile_image_url', $star['rel_uid']);
		if(isset($star['remark'])){
			$rel_remark = F('escape', $star['rel_remark']);
		}elseif(isset($star['description'])){
			$rel_remark = F('escape', $star['description']);
		}else{
			$rel_remark = '';
		}
		
		$profile_url = URL('ta', array('id' => $star['uid']));
		$row = $star;
?>
		<div class="user-item" rel="u:<?php echo $uid;?>">
			<div class="user-pic">
				<a href="<?php echo URL('ta', 'id=' . $uid . '&name='. $nick);?>"><img src="<?php echo $user_img?>" alt="<?php LO('modules__modSearchUserPre__profileImageUrl', F('escape', $nick));?>" /></a>
			</div>
            
			<?php if ($row['following']) {?>
			<span class="followed-btn"><?php LO('common__template__followed');?></span>
			<?php } else {?>
			<a class="addfollow-btn"  rel="e:fl,t:1" href="#"><span class="plus">+</span><?php LO('common__template__toFollow');?></a>
			<?php }?>
			
			<div class="user-info">
				<a class="u-name" href="<?php echo URL('ta', 'id=' . $uid . '&name=' . urlencode($nick));?>"><?php echo htmlspecialchars($nick); echo F('verified', $row); ?></a>
				<p><?php echo htmlspecialchars(mb_strwidth($remark, 'UTF-8') > 30 ? mb_substr($remark, 0, 13, 'UTF-8') . '...' : $remark); ?></p>
			</div>
			
		</div>	
	
		<div class="user-item" rel="u:<?php echo $rel_uid;?>">
			<div class="user-pic">
				<a href="<?php echo URL('ta', 'id=' . $rel_uid . '&name='. $rel_nick);?>"><img src="<?php echo $rel_user_img?>" alt="<?php LO('modules__modSearchUserPre__profileImageUrl', F('escape', $rel_nick));?>" /></a>
			</div>
            
			<?php if ($row['rel_following']) {?>
			<span class="followed-btn"><?php LO('common__template__followed');?></span>
			<?php } else {?>
			<a class="addfollow-btn"  rel="e:fl,t:1" href="#"><span class="plus">+</span><?php LO('common__template__toFollow');?></a>
			<?php }?>
			
			<div class="user-info">
				<a class="u-name" href="<?php echo URL('ta', 'id=' . $rel_uid . '&name=' . urlencode($rel_nick));?>"><?php echo htmlspecialchars($rel_nick); echo F('verified', $row); ?></a>
				<p><?php echo htmlspecialchars(mb_strwidth($rel_remark, 'UTF-8') > 30 ? mb_substr($rel_remark, 0, 13, 'UTF-8') . '...' : $rel_remark); ?></p>
			</div>
			
		</div>	
	<?php
	
	} 
	echo '</div>';
		}else {
	?>
	<div class="search-result">
        <div class="icon-alert"></div>
		<p><strong><?php LO('modules__modSearchUserPre__emptyTip');?></strong></p>
    </div>
	<?php
	}
	?>
	</div>

	<!-- 分组用户列表TAB结束 -->
                        	</div>
                        
                        </div>
						<div class="aside">
							<!-- 右边推荐关注-->
							<div class="mod-aside">							
								
								<?php
									if (isset($comWeibos) && is_array($comWeibos) && !empty($comWeibos)) {
								?>
								<div class="gt-commend-btn"><a href="#"  id="btnOK" class="btn-s2"><span>一键关注</span></a></div>
								<div class="hd"><h3>推荐关注</h3></div>
								<div id="chklist">
									<?php foreach ($comWeibos as $comWeibo) {?>
									<div>
									<input class="gt-commend-chk" name="gtcheckbox" checked="true" type="checkbox" value="<?php echo $comWeibo['uid'];?>"/><span class="gt-commend-name"><a href="/index.php?m=ta&id=<?php echo $comWeibo['uid'];?>"><?php echo $comWeibo['nickname'];?></a></span>
									</div>
									<?php }?>
								</div>
								<?php }else{?>
									<div class="gt-commend-btn"><a href="#"  id="btnOK" class="btn-s2 btn-s2gt"><span>一键关注</span></a></div>
									<div class="hd"><h3>匹配关注</h3></div>
									<div id="chklist">
										暂无匹配推荐
									</div>
								<?php }?>
								</div>
							
							<script type="text/javascript">
							  $("#chkbtn").click(function(){
								         
								  $("[name='gtcheckbox']").attr("checked",'true');//全选
							       
							    });

							  $("#btnOK").click(function(){
								  var ids = [];
								  var s='';
								  $('input[name="gtcheckbox"]:checked').each(function(){
								      s+=$(this).val()+',';
								      ids.push($(this).val());
								  });
								  
								  if(!ids.length){
									  Xwb.ui.MsgBox.tipWarn('请选择您要关注的折扣微博。' );
	                                }else {
	                                	Xwb.request.follow(ids.join(','), 0, function(r){
	                                        if (r.isOk()) {
		                                        Xwb.ui.MsgBox.tipOk('成功关注折扣微博');
	                                        } else {
	                                        	Xwb.ui.MsgBox.tipWarn(r.getMsg());
	                                        }
	                                    });
	                                }           
							       
							    });
							
							</script>
							<!-- 右边推荐关注结束-->
							<?php Xpipe::pagelet('common.sideComponents', array('type'=>2) );?>
						<?php echo F('show_ad', 'sidebar', '');?>
						</div>
					</div>
				</div>
			</div>
			<!-- 尾部 开始 -->
            <?php TPL::module('footer');?>
			<!-- 尾部 结束 -->
		</div>
	</div>
	<?php TPL::module('gotop');?>
</body>
</html>
